﻿using System;
using RAP.Framework.Libary.DomTemplateBuilder.Attributes;
using RAP.Framework.Libary.DomTemplateBuilder.Handler.ArrayListActions.Add;
using RAP.Framework.Libary.Utils;

namespace RAP.Framework.Libary.DomTemplateBuilder.Element.ArrayListActions.Add
{
	/// <summary>
	/// 添加字典项节点
	/// </summary>
	[TagHandler( "ArrayList.Value", typeof( AddValueActionHandler ) )]
    public class AddValueAction : ArrayListAddAction
    {
        private TypeCode? _type = null;
		/// <summary>
		/// 值类型
		/// </summary>
		public TypeCode ValueType
        {
            get
            {
                if ( _type == null )
                {
					_type = this.ToEnumValue<TypeCode> ( "ValueType", TypeCode.String );
                }
                return _type.Value;
            }
        }

		private bool? _single = null;
		/// <summary>
		/// 值是否允许重复，默认不允许
		/// </summary>
		public bool Single
		{
			get
			{
				if ( _single == null )
				{
					_single = this.ToBoolean ( "Single", true );
				}
				return _single.Value;
			}
		}

		/// <summary>
		/// 是否忽略空字符串
		/// </summary>
		public bool IgnoreEmpty
		{
			get
			{
				return this.ToBoolean ( "IgnoreEmpty" );
			}
		}
    }
}
